<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
</head>
<body>
    <div id="app">
        <!-- 自定义时间diy，myfun（）是VUE对象的方法 -->
        <zhangsan @diy="myfun"></zhangsan>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>

    <script>
        Vue.component("zhangsan",{
            template:`
                <button @click="myclick">按钮myclick</button> 
            `,
            methods:{
                myclick:function(){
                    this.$emit('diy',{name:"zhangsan"})
                }
            }
        })
        var vue =new Vue({
            el:"#app",
            methods:{
                myfun:function(data){
                    alert(data.name)
                }
            }
        })  
    </script>
</body>
</html>